//
//  BaseTableViewCell.m
//  GLGW_Shoping
//
//  Created by yang on 2018/11/8.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "BaseTableViewCell.h"

@interface BaseTableViewCell (){
    UIView * lineView;
    GLGWImageView * pushImageView;
}
@end

@implementation BaseTableViewCell

+ (instancetype)cellWithTableView:(UITableView *)tableView {
    BaseTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([self class])];
    if (!cell) {
        cell = [[[self class] alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([self class])];
        
    }
    return cell;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor whiteColor];
        [self setupUI];
    }
    return self;
}
#pragma mark =================== 初始化页面 ===================
-(void)setupUI{
    pushImageView = [[GLGWImageView alloc] initWithImageName:@"icon_chakan" inSuperView:self.contentView];
    pushImageView.hidden = YES;
//    pushImageView.backgroundColor = kRandomColor;
    [pushImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.right.equalTo(self.mas_right).offset(-kHeightProportion_In_iPhoneTriploid(15));
        make.width.equalTo(@(kWidthProportion_In_iPhoneTriploid(10)));
        make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(16)));
    }];
}

-(void)setSepartionLineWith:(lineModel)aline{
    if (aline == lineModel_All) {
        lineView = [[UIView alloc] init];
        lineView.backgroundColor = [UIColor colorWithHexString:@"E9EBF0"];
        [self addSubview:lineView];
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self).offset(0);
            make.bottom.equalTo(self.mas_bottom).offset(0);
            make.height.equalTo(@1);
        }];
    }else{
        lineView = [[UIView alloc] init];
        lineView.backgroundColor = [UIColor colorWithHexString:@"E9EBF0"];
        [self addSubview:lineView];
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.mas_left).offset(10);
            make.right.equalTo(self.mas_right).offset(-10);
            make.bottom.equalTo(self.mas_bottom).offset(0);
            make.height.equalTo(@1);
        }];
    }
}
#pragma mark -- set

-(void)hiderLine:(BOOL)hiderBool{
    lineView.hidden = hiderBool;
}

-(void)setShowPush:(BOOL)showPush{
    _showPush = showPush;
    pushImageView.hidden = !_showPush;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
